﻿// ----------------------------------------------------------------------------
//  Copyright (C) 成都联宇创新科技有限公司 版权所有。 
//      
//  文件名：CommonLoggingLogger.cs
//  文件功能描述：
//  创建标识：骆智慧 2016/03/04 11:41
//     
//  修改标识：骆智慧  2016/03/10/06:27
//  修改描述：
//  ----------------------------------------------------------------------------

#region 导入名称空间

using System;
using Common.Logging;
using NHibernate;

#endregion

namespace LightWork.NHibernate.CommonLogging
{
    /// <summary>
    /// Implements the <see cref="IInternalLogger" /> interface to allow the usage
    /// of Common.Logging 2.1 with the NHibernate logging infrastructure.
    /// </summary>
    public class CommonLoggingLogger : IInternalLogger
    {
        private readonly ILog logger;

        public CommonLoggingLogger(ILog logger)
        {
            this.logger = logger;
        }

        public void Error(object message)
        {
            this.logger.Error(message);
        }

        public void Error(object message, Exception exception)
        {
            this.logger.Error(message, exception);
        }

        public void ErrorFormat(string format, params object[] args)
        {
            this.logger.ErrorFormat(format, args);
        }

        public void Fatal(object message)
        {
            this.logger.Fatal(message);
        }

        public void Fatal(object message, Exception exception)
        {
            this.logger.Fatal(message, exception);
        }

        // Note: No FatalFormat() in ILogger-Interface available.
        /*public void FatalFormat(string format, params object[] args)
		{
			this.logger.FatalFormat(format, args);
		}*/

        public void Debug(object message)
        {
            this.logger.Debug(message);
        }

        public void Debug(object message, Exception exception)
        {
            this.logger.Debug(message, exception);
        }

        public void DebugFormat(string format, params object[] args)
        {
            this.logger.DebugFormat(format, args);
        }

        public void Info(object message)
        {
            this.logger.Info(message);
        }

        public void Info(object message, Exception exception)
        {
            this.logger.Info(message, exception);
        }

        public void InfoFormat(string format, params object[] args)
        {
            this.logger.InfoFormat(format, args);
        }

        public void Warn(object message)
        {
            this.logger.Warn(message);
        }

        public void Warn(object message, Exception exception)
        {
            this.logger.Warn(message, exception);
        }

        public void WarnFormat(string format, params object[] args)
        {
            this.logger.WarnFormat(format, args);
        }

        public bool IsErrorEnabled
        {
            get { return this.logger.IsErrorEnabled; }
        }

        public bool IsFatalEnabled
        {
            get { return this.logger.IsFatalEnabled; }
        }

        public bool IsDebugEnabled
        {
            get { return this.logger.IsDebugEnabled; }
        }

        public bool IsInfoEnabled
        {
            get { return this.logger.IsInfoEnabled; }
        }

        public bool IsWarnEnabled
        {
            get { return this.logger.IsWarnEnabled; }
        }
    }
}